package com.lanou.moving.adapter;

import android.app.ProgressDialog;
import android.content.Context;
import android.os.Environment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.lanou.moving.R;
import com.lanou.moving.entity.SearchSingerSong;
import com.lanou.moving.view.CommonProgressDialog;

import java.io.File;
import java.util.List;

/**
 * Created by dllo on 15/10/28.
 */
public class SingerContentSongAdapter extends BaseAdapter {
    private Context context;
    private List<SearchSingerSong.DataEntity> datas;
    private int size;

    public SingerContentSongAdapter(Context context, List<SearchSingerSong.DataEntity> data) {
        this.context = context;
        this.datas = data;
    }


    @Override
    public int getCount() {
        return datas != null && datas.size() > 0 ? datas.size() : 0;
    }

    @Override
    public Object getItem(int position) {
        return datas != null && datas.size() > 0 ? datas.get(position) : null;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder = null;
        if (convertView == null) {
            convertView = LayoutInflater.from(context).inflate(R.layout.songs_list_listview_item, null);
            holder = new ViewHolder();
            holder.songs_list_position = (TextView) convertView.findViewById(R.id.songs_list_position);
            holder.songs_list_songName = (TextView) convertView.findViewById(R.id.songs_list_songName);
            holder.songs_list_item_singer = (TextView) convertView.findViewById(R.id.songs_list_item_singer);
            holder.songs_list_item_number = (TextView) convertView.findViewById(R.id.songs_list_item_number);
            holder.list_more = (ImageView) convertView.findViewById(R.id.list_more);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }
        final SearchSingerSong.DataEntity entity = (SearchSingerSong.DataEntity) getItem(position);
        if (entity != null) {
            holder.songs_list_position.setText(position + 1 + "");
            holder.songs_list_songName.setText(entity.getName());
            holder.songs_list_item_singer.setText(entity.getSingerName());
            holder.songs_list_item_number.setText(entity.getFavorites());
            holder.list_more.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {

                }
            });

        }
        return convertView;
    }

    private class ViewHolder {
        private TextView songs_list_position, songs_list_songName,
                songs_list_item_singer, songs_list_item_number;
        private ImageView list_more;
    }
}
